
#ifndef DynamicSoundEffectInstance_h
#define DynamicSoundEffectInstance_h

#include <CSharpPropertyMethods.h>

#include <System/Generic/EventHandler.h>
#include <System/EventArgs.h>
#include <System/TimeSpan.h>

#include "SoundEffectInstance.h"

namespace Riccsson
{
	namespace Xna
	{
		namespace Framework
		{
			namespace Audio
			{
				// Forward decleration.
				class _SoundEngineBase;

				// Summary:
				//     Provides a single playing, paused, or stopped instance of a SoundEffect sound.
				class DynamicSoundEffectInstance sealed : public SoundEffectInstance
				{
					private: _SoundEngineBase* m_soundEngine;

					public: Void _OnBufferNeeded(GC_PTR<System::Object> sender, GC_PTR<System::EventArgs> args);

				protected:

					PROP3GET(DynamicSoundEffectInstance, int, PendingBufferCount);
						
					COPY_CONSTRUCTOR(DynamicSoundEffectInstance)
					{
						PROP3GET_INIT_COPY(DynamicSoundEffectInstance, int, PendingBufferCount);
					}

					// Summary:
					//     Initializes a new instance of this class, which creates a dynamic sound effect
					//     based on the specified sample rate and audio channel.
					//
					// Parameters:
					//   sampleRate:
					//     Sample rate, in Hertz (Hz), of audio content.
					//
					//   channels:
					//     Number of channels in the audio data.
					public: DynamicSoundEffectInstance(int sampleRate, AudioChannels channels);

					// Summary:
					//     Indicates whether the audio playback of the DynamicSoundEffectInstance object
					//     is looped.
					public: override PROP3_GET(bool, IsLooped)
					{
						throw;
					}
					public: override PROP3_SET(bool, IsLooped)
					{
						throw;
					}

					//
					// Summary:
					//     Returns the number of audio buffers in the queue awaiting playback.
					public: PROP3_GET(int, PendingBufferCount)
					{
						throw;
					}

					// Summary:
					//     Event that occurs when the number of audio capture buffers awaiting playback
					//     is less than or equal to two.
					//
					// Parameters:
					//   :
					public: event<Void, Riccsson::System::Generic::EventHandler<Riccsson::System::EventArgs>> BufferNeeded;

					protected: override void Dispose(bool disposing);
					//
					// Summary:
					//     Returns the sample duration based on the specified size of the audio buffer.
					//
					// Parameters:
					//   sizeInBytes:
					//     Size, in bytes, of the audio data.
					public: Riccsson::System::TimeSpan GetSampleDuration(int sizeInBytes);
					//
					// Summary:
					//     Returns the size of the audio buffer required to contain audio samples based
					//     on the specified duration.
					//
					// Parameters:
					//   duration:
					//     TimeSpan object that contains the duration of the audio sample.
					public: int GetSampleSizeInBytes(Riccsson::System::TimeSpan duration);
					//
					// Summary:
					//     Begins or resumes audio playback.
					public: override void Play();
					//
					// Summary:
					//     Submits an audio buffer for playback. Playback starts at the beginning, and
					//     the buffer is played in its entirety. Reference page contains links to related
					//     conceptual articles.
					//
					// Parameters:
					//   buffer:
					//     Buffer that contains the audio data. The audio format must be PCM wave data.
					public: void SubmitBuffer(Riccsson::System::Array<byte>* buffer);
					public: void SubmitBuffer(byte* buffer);

					//
					// Summary:
					//     Submits an audio buffer for playback. Playback begins at the specifed offset,
					//     and the byte count determines the size of the sample played. Reference page
					//     contains links to related conceptual articles.
					//
					// Parameters:
					//   buffer:
					//     Buffer that contains the audio data. The audio format must be PCM wave data.
					//
					//   offset:
					//     Offset, in bytes, to the starting position of the data.
					//
					//   count:
					//     Amount, in bytes, of data sent.
					public: void SubmitBuffer(Riccsson::System::Array<byte>* buffer, int offset, int count);
				};
			}
		}
	}
}

#endif